#ifndef CTIMEHELPER_H
#define CTIMEHELPER_H
#include "common/commonDefFun.h"

namespace libcvos_vfr
{
	namespace Helper
	{
		typedef struct
		{
			int year;
			int month;
			int day;
			int hour;
			int minute;
			int second;
			int millisecond;
		}DateTimeWithMilsec;

		TOOL_SDK_API void DLL_SPEC Tool_GetCurrentTimeToString(char* timeStrngBuf, int bufLen);

		TOOL_SDK_API unsigned long long DLL_SPEC Tool_ConvertToTimeTick(int iYear, int iMonth, int iDay, int iHour, int iMin, int iSecond, int iMsecond);

		TOOL_SDK_API long long DLL_SPEC Tool_GetTickCount();

		TOOL_SDK_API long long DLL_SPEC Tool_GetTimeSecond();

		TOOL_SDK_API void DLL_SPEC Tool_GetDateTimeWithMillisecond(DateTimeWithMilsec* timeStruct);

		//TOOL_SDK_API tm DLL_SPEC Tool_TimeNowTm();

		/// <summary>
		/// get time stirng like '"%04d%02d%02d%02d%02d%02d%03d"'
		/// </summary>
		/// <param name="timeStrngBuf">buff address</param>
		/// <param name="bufLen">buf len</param>
		/// <returns>success: true ; failed: false</returns>
		TOOL_SDK_API bool DLL_SPEC Tool_GetTimeString(char* timeStrngBuf, int bufLen);

		TOOL_SDK_API bool DLL_SPEC Tool_ConverTimeTickWithMsToString(unsigned long long timeTick, char* buff, int bufLen);

		/// <summary>
		/// convert time string like "%d-%d-%d %d:%d:%d" or "%d-%d-%d %d:%d:%d:%d" to timet tick
		/// </summary>
		/// <param name="timeString">"2014-07-25 20:17:12" or "2014-07-25 20:17:12:123"</param>
		/// <returns>time tick with ms second</returns>
		TOOL_SDK_API unsigned long long DLL_SPEC Tool_ConvertTimeStringToTick64(const char* timeString);

		TOOL_SDK_API bool DLL_SPEC Tool_CheckIfDateTimeIsValid(int iYear, int iMonth, int iDay, int iHour, int iMinute, int iSecond);

        /// <summary>
        /// 	convert  dateTimeFormat{"%Y-%m-%dT%H:%M:%SZ" } or dateTimeFormat{ "%Y/%m/%d %H:%M:%S" };  to timet tick
        /// </summary>
        /// <param name="timeString">time string like '2014-07-25T20:17:22Z'</param>
        /// <param name="timeFormat">format "%Y/%m/%d %H:%M:%S" or </param>
        /// <returns>time_t</returns>
        TOOL_SDK_API long long DLL_SPEC Tool_ConvertTimeStringToTimeTick(const char* timeString, const char* timeFormat);

        /// <summary>
        /// convert datetime like '2014-07-25 20:17:123' to timet tick
        /// </summary>
        /// <param name="timeString">time string like '2014-07-25 20:17:123'</param>
        /// <param name="timeFormat">scanf format '%d-%d-%d %d:%d:%d'</param>
        /// <returns>time tick</returns>
        TOOL_SDK_API long long DLL_SPEC Tool_ConvertTimeStringToTimeTick_sscanfversion(const char* timeString, const char* timeFormat);
	}
}


#endif
